#!/usr/bin/python3
# -*- coding: utf-8 -*-
# @Author : Tinfeng

import re
import time

from selenium import webdriver
from page.LoginPage import LoginPage
from utils.Logger import Logger

'''
在此文件中增加对元素的操作
'''
logger = Logger(logger='LoginHandle').getlog()

class LoginHandle:
    def __init__(self,i):
        self.loginPage = LoginPage(i)

    def sendUsername(self):
        '''
        输入用户名
        :return:
        '''
        return self.loginPage.getUsernameElement().send_keys('xxxxxx')

    def sendPassword(self):
        '''
        输入密码
        :return:
        '''
        return self.loginPage.getPasswordElement().send_keys('xxxxxxx')

    def sendCaptcha(self):
        '''
        输入验证码
        :return:
        '''
        return self.loginPage.getCaptchaElement().send_keys('1234')

    def clickLogin(self):
        '''
        点击登录
        :return:
        '''
        return self.loginPage.getLoginElement().click()

    def clickRoleBox(self):
        '''
        点击角色框
        :return:
        '''
        return self.loginPage.getRoleBoxElement().click()

    def choiceRole(self):
        '''
        选择角色
        :return:
        '''
        return self.loginPage.getRoleObject()

    def clickSure(self):
        '''
        点击确定
        :return:
        '''
        return self.loginPage.getSureElement().click()

    def clickDkdOuter(self):
        '''
        点击第一个贷款单
        :return:
        '''
        return self.loginPage.getDkdOuterElement().click()

    def clickDkdInner(self):
        '''
        点击第二个贷款单
        :return:
        '''
        return self.loginPage.getDkdInnerElement().click()

    def switchIframe(self,iframeId):
        '''
        切换iframe框架
        :return:
        '''
        return self.loginPage.switchIframe(iframeId)

    def sendDkdNum(self):
        '''
        输入贷款单编号
        :return:
        '''
        return self.loginPage.getSendDkdNumElement().send_keys('20201223000004')

    def clickSearch(self):
        '''
        点击搜索按钮
        :return:
        '''
        time.sleep(2)
        return self.loginPage.getSearchElement().click()

    def clickOnList(self):
        '''
        点击搜索出的当前行元素
        :return:
        '''
        time.sleep(3)
        return self.loginPage.getOnListElement().click()

    def clickListInfo(self):
        '''
        点击详情
        :return:
        '''
        time.sleep(3)
        return self.loginPage.getListInfoElement().click()